<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="/content/script.js"></script>
    <link rel="stylesheet" href="/content/style.css" type="text/css" />
    <title>Login page</title>
<head>
<body class="mid">
    <fieldset>
        <legend>Login page</legend>
        <c:if test="${sessionScope.USER eq null}">
        <form:form commandName="user">
            <form:errors path="*" cssClass="errorBox" />
            <table>
            <tr>
                <td><label for="userName">User name</label></td>
                <td><form:input id="userName" path="userName" /></td>
                <td><form:errors path="userName" cssClass="error" /></td>
            </tr>
            <tr>
                <td><label for="password">Password</label></td>
                <td><form:password id="password" path="password" /></td>
                <td><form:errors path="password" cssClass="error" /></td>
            </tr>
            <tr>
                <td colspan="3" style="text-align: right">
                    <input type="submit" value="Log in" />
                    &nbsp;
                    <input type="reset" />
                </td>
            </tr>
            </table>
        </form:form>
        </c:if>
        <c:if test="${sessionScope.USER ne null}">
        <p>Hi ${sessionScope.USER}, Please <a href="logout">logout</a>.</p>
        </c:if>
    </fieldset>
</body>
</html>
